<?php

namespace App\Http\Controllers\Admin;

use App\Http\Model\Orders;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Input;

class OrdersController extends Controller
{
    public function index()
    {
        $arr = [1=>"未支付",2=>"已支付"];
        $array = [1=>"未发货",2=>"已发货",3=>"已收货",4=>"退货"];
        $list = \DB::table("orders")->where('order_status','1')->get();
//        给模板传变量的三种方
        return  view('admin.orders.index',compact('list',"arr","array"));
    }


    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $list = \DB::table("orders")->where('cargo_status','2')->get();
//        给模板传变量的三种方
        return  view('admin.orders.index',compact('list'));
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        //
    }
    public function aa()
    {
        //已发货的订单
        $arr = [1=>"未支付",2=>"已支付"];
        $array = [1=>"未发货",2=>"已发货",3=>"已收货",4=>"退货"];
        $list = \DB::table("orders")->where('cargo_status','2')->get();
//        给模板传变量的三种方
        return  view('admin.orders.index',compact('list',"arr","array"));
    }
    public function bb()
    {
        //已发货的订单
        $arr = [1=>"未支付",2=>"已支付"];
        $array = [1=>"未发货",2=>"已发货",3=>"已收货",4=>"退货"];
        $list = \DB::table("orders")->where('cargo_status','3')->get();
//        给模板传变量的三种方
        return  view('admin.orders.index',compact('list',"arr","array"));
    }
    public function cc()
    {
        //已发货的订单
        $arr = [1=>"未支付",2=>"已支付"];
        $array = [1=>"未发货",2=>"已发货",3=>"已收货",4=>"退货"];
        $list = \DB::table("orders")->where('cargo_status','4')->get();
//        给模板传变量的三种方
        return  view('admin.orders.index',compact('list',"arr","array"));
    }

    /**
     * Show the form for editing the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function edit($id)
    {
        $data = Orders::find($id);
        return view('admin.orders.edit',compact('data'));
    }

    /**
     * Update the specified resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, $id)
    {

        $input = Input::except('_token','_method');
        $art = Orders::find($id);
        $re =  $art->update($input);
        if($re){
            return redirect('admin/orders');
        }else{
            return back()->with('errors','商品修改失败');
        }
    }

    /**
     * Remove the specified resource from storage.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function destroy($id)
    {
        //
    }
}
